package comtwo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class Demo1 {
    public static void main(String[] args) {

        //线程安全的集合
       /* List<Object> objects = Collections.synchronizedList();
        objects.add(5);*/

        List list = new ArrayList();
        //增，删，改，查
        list.add(5);
        list.add(2);
        list.add(3);
        list.set(0,5);

        //查
       /* list.get(0);
        for (int i=0;i<list.size();i++){
            list.get(i);
        }*/

        //删
        /*list.remove(0);
        System.out.println(list.get(0).toString());*/

        //修
        System.out.println(list.set(0,2));
        System.out.println(list.get(0).toString());
        System.out.println(list.get(1).toString());
        //其他的方法：
        boolean contains = list.contains(5);
        System.out.println(contains);

        String string = list.toArray().toString();
        System.out.println(string);
    }
}
